package cn.ichiva.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class PropertiesUtil {

	private static FileInputStream in = null;
	private static Properties p = new Properties();

	static {
		try {
			in = new FileInputStream("config.properties");
			p.load(in);
		} catch (IOException e) {
			throw new RuntimeException(e.getMessage());
		}
	}

	public static String get(String key) {
		return p.getProperty(key);
	}
	
	public static void set(String key,String value) {
		p.setProperty(key, value);
	}

	public static Object getBean(String classNameKey)
			throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		return Class.forName(get(classNameKey)).newInstance();
	}

}
